import http from '@/utils/http'

const BASE_URL = '/cakerun/feedback'

export interface FeedbackResp {
  id: string
  accountId: string
  shopId: string
  avgScore: string
  totalCount: string
  badCount: string
  goodCount: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface FeedbackDetailResp {
  id: string
  accountId: string
  shopId: string
  avgScore: string
  totalCount: string
  badCount: string
  goodCount: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface FeedbackQuery {
  sort: Array<string>
  accountId: Array<string>
}
export interface FeedbackPageQuery extends FeedbackQuery, PageQuery {}

/** @desc 查询门店评价列表 */
export function listFeedback(query: FeedbackPageQuery) {
  return http.get<PageRes<FeedbackResp[]>>(BASE_URL, query)
}

/** @desc 查询门店评价详情 */
export function getFeedback(id: string) {
  return http.get<FeedbackDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增门店评价 */
export function addFeedback(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改门店评价 */
export function updateFeedback(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除门店评价 */
export function deleteFeedback(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出门店评价 */
export function exportFeedback(query: FeedbackQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
